﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace space_scavenger
{
    public abstract class Entity
    {
        private Vector2 position;
        private Vector2 velocity; //pixels per second
        private Rectangle hitbox;
        private Texture2D sprite;


        public Vector2 Position
        {
            get
            {
                return position;
            }
            set
            {
                position = value;
            }
        }

        public Vector2 Velocity
        {
            get
            {
                return velocity;
            }
            set
            {
                velocity = value;
            }
        }

        public Rectangle HitBox
        {
            get
            {
                return hitbox;
            }
            set
            {
                hitbox = value;
            }
        }

        public int PositionX
        {
            get
            {
                return (int)position.X;
            }
            set
            {
                position.X = value;
            }
        }

        public int PositionY
        {
            get
            {
                return (int)position.Y;
            }
            set
            {
                position.Y= value;
            }
        }

        public float VelocityX
        {
            get
            {
                return position.X;
            }
            set
            {
                velocity.X = value;
            }
        }

        public float VelocityY
        {
            get
            {
                return velocity.Y;
            }
            set
            {
                velocity.Y = value;
            }
        }

        public Texture2D Sprite
        {
            get
            {
                return sprite;
            }
            set
            {
                sprite = value;
            }
        }

        public Entity(Vector2 position, Vector2 velocity, Rectangle rect, Texture2D image)
        {
            Position = position;
            Velocity = velocity;
            HitBox = rect;
            Sprite = image;
        }

        public virtual void Update(InputState inputState, GameTime gameTime)
        {
            position.X += velocity.X * (float)gameTime.ElapsedGameTime.TotalSeconds;
            position.Y += velocity.Y * (float)gameTime.ElapsedGameTime.TotalSeconds;


        }

        public virtual void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {

            spriteBatch.Begin();
            spriteBatch.Draw(sprite, position, new Rectangle(0, 0, sprite.Width, sprite.Height), Color.White);
            //spriteBatch.Draw(sprite, new Rectangle(PositionX, PositionY, sprite.Width, sprite.Height), Color.White);
            spriteBatch.End();
        }
    }
}
